<template>
  <el-form :model="article" label-width="150px">
    <h3>记事本</h3>
    <el-form-item label="标题" prop="title">
      <el-input v-model="article.title"></el-input>
    </el-form-item>
    <el-form-item label="内容" prop="content">
      <el-input v-model="article.content" type="textarea" :rows="15"></el-input>
    </el-form-item>
    <el-button type="primary" @click="submitForm">保存</el-button>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      article: {
        title: '',
        content: ''
      }
    }
  },
  methods: {
    submitForm() {
      console.log(this.article);
      this.saveArticle();
    },
    saveArticle() {
      // 调用后端接口保存文章内容的具体逻辑
      this.$axios.post('http://localhost:8181/articleForm/saveArticle',this.article)
      .then(resp => {
        // 处理响应结果
        console.log(resp.data);
        this.$message({
          message: '新增/修改，成功',
          type: 'success'
        });
         // 跳转到其他页面
        this.$router.push('/Show');
      }).catch(error => {
          // 处理错误
           console.error(error);
      });
    }
  }
}
</script>

<style scoped>
.el-form-item {
  margin-right: 150px;
}
</style>